package edu.drexel.cs575.taskManager.common;

import javax.xml.ws.BindingProvider;

import edu.drexel.cs575.taskManager.common.serviceDropSpot.broker.BrokerCaller;
import edu.drexel.cs575.taskManager.common.serviceDropSpot.broker.BrokerCallerService;
import edu.drexel.cs575.taskManager.common.serviceDropSpot.group.GroupCaller;
import edu.drexel.cs575.taskManager.common.serviceDropSpot.group.GroupCallerService;
import edu.drexel.cs575.taskManager.common.serviceDropSpot.manager.ServiceManager;
import edu.drexel.cs575.taskManager.common.serviceDropSpot.manager.ServiceManagerService;
import edu.drexel.cs575.taskManager.common.serviceDropSpot.notification.NotificationCaller;
import edu.drexel.cs575.taskManager.common.serviceDropSpot.notification.NotificationCallerService;
import edu.drexel.cs575.taskManager.common.serviceDropSpot.user.UsermgmtCaller;
import edu.drexel.cs575.taskManager.common.serviceDropSpot.user.UsermgmtCallerService;

public class ServiceFactory {
	
	/**
	 * This class should never be instantiated
	 */
	private ServiceFactory(){
		
	}
	
	public static ServiceManager getServiceManager() {
        ServiceManagerService shs = new ServiceManagerService();
		
        ServiceManager serviceManager = (ServiceManager) shs.getServiceManagerPort();
		
        ((BindingProvider)serviceManager).getRequestContext().put(BindingProvider.
            ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8081/serviceManager");

        return serviceManager;
	}
	
	public static BrokerCaller getTaskService(){
		BrokerCallerService brokerService = new BrokerCallerService();
		
		BrokerCaller taskBroker = (BrokerCaller) brokerService.getBrokerCallerPort();
		
        ((BindingProvider)taskBroker).getRequestContext().put(BindingProvider.
            ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8084/broker");

        return taskBroker;
	}
	
	public static GroupCaller getGroupService(){
		GroupCallerService brokerService = new GroupCallerService();
		
		GroupCaller taskBroker = (GroupCaller) brokerService.getGroupCallerPort();
		
        ((BindingProvider)taskBroker).getRequestContext().put(BindingProvider.
            ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8082/group");

        return taskBroker;
	}
	
	public static NotificationCaller getNotificationService(){
		NotificationCallerService brokerService = new NotificationCallerService();
		
		NotificationCaller taskBroker = (NotificationCaller) brokerService.getNotificationCallerPort();
		
        ((BindingProvider)taskBroker).getRequestContext().put(BindingProvider.
            ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8083/notification");

        return taskBroker;
	}
	
	public static UsermgmtCaller getUserService(){
		UsermgmtCallerService brokerService = new UsermgmtCallerService();
		
		UsermgmtCaller taskBroker = (UsermgmtCaller) brokerService.getUsermgmtCallerPort();
		
        ((BindingProvider)taskBroker).getRequestContext().put(BindingProvider.
            ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8085/User");

        return taskBroker;
	}
}
